<?php
/**
 * Smart Library - Smart Framework
 * http://smart-framework.highet.eu
 *
 * @category   SmartL
 * @package    SmartL_Zend
 * @subpackage View
 * @copyright  Copyright (c) 2005-2008 Smart Framework team - Stepan Sindelar, Vojtech Vit
 * @license    http://www.opensource.org/licenses/bsd-license.php	New BSD License
 */

/**
 * @see Zend_View_Helper_Url
 */
require_once 'Zend/View/Helper/Url.php';
/**
 * @see SmartL_Application
 */
require_once 'SmartL/Application.php';

/**
 * Helper for fast handling dates via Zend_Date class.
 *  
 * It is very expensive to create instance of Zend_Date class, and so creating instances of Zend_Date
 * for example during some loop in view can be very slow.
 * 
 * This helper is pool of one Zend_Date instance which can be simply used for date handling.
 * The instance is recycled when the helper is called again.
 *
 * @package SmartL_Zend
 * @subpackage View
 */
class SmartL_Zend_View_Helper_Date  
{
	/**
	 * Recycled instance of Zend_Date.
	 *
	 * @var Zend_Date
	 */
	private $_date;
	
	/**
	 * Constructs new instance of date.
	 */
	public function __construct()
	{
		$this->_date = new Zend_Date();
	}
	
	/**
	 * @return Zend_Date
	 */
	public function date($date, $part = null)
	{
		$this->_date->set($date, $part);
		return $this->_date;
	}
}